home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Milan_1991 / Devcon91.4 / AdaptingToFonts / Example2Strings.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-01  |  4.3 KB  |  136 lines

  1. /*
  2.  * Example 2 - Based on the UI code for FontMover 2.0 by Michael Sinz
  3.  *
  4.  * Copyright (c) 1989,90 - MKSoft Development
  5.  *
  6.  ************************************************************************
  7.  *                                                                      *
  8.  *                            DISCLAIMER                                *
  9.  *                                                                      *
  10.  *   THIS SOFTWARE IS PROVIDED "AS IS".                                 *
  11.  *   NO REPRESENTATIONS OR WARRANTIES ARE MADE WITH RESPECT TO THE      *
  12.  *   ACCURACY, RELIABILITY, PERFORMANCE, CURRENTNESS, OR OPERATION      *
  13.  *   OF THIS SOFTWARE, AND ALL USE IS AT YOUR OWN RISK.                 *
  14.  *   NEITHER COMMODORE NOR THE AUTHORS ASSUME ANY RESPONSIBILITY OR     *
  15.  *   LIABILITY WHATSOEVER WITH RESPECT TO YOUR USE OF THIS SOFTWARE.    *
  16.  *                                                                      *
  17.  ************************************************************************
  18.  */
  19.  
  20. #include    <exec/types.h>
  21. #include    <intuition/intuition.h>
  22.  
  23. #include    <proto/intuition.h>
  24.  
  25. #include    <string.h>
  26.  
  27. #include    "Example2Strings.h"
  28.  
  29. /*
  30.  * This file contains the global strings.  It may, at some point be set up
  31.  * for internationalization.
  32.  */
  33.  
  34. static    char    *All_Strings[STRING_TOO_FAR+1]=
  35. {
  36.  
  37. /*
  38.  * These strings are for the main gadgets...
  39.  */
  40. /* TXT_CopyRightString            */    "Copy >",
  41. /* TXT_CopyLeftString            */    "< Copy",
  42. /* TXT_CopyGadgetString            */    "Copy",
  43.  
  44. /* TXT_RemoveGadgetString        */    "Remove",
  45. /* TXT_ShowGadgetString            */    "Show",
  46. /* TXT_HelpGadgetString            */    "Help",
  47. /* TXT_AboutGadgetString        */    "About",
  48.  
  49. /*
  50.  * This is tha last string that is used in any way for
  51.  * scaling the display.  This is the string between the
  52.  * arrows that let you select the font directory.
  53.  */
  54. /* TXT_DirSelectGadget            */    "Select",
  55.  
  56. /*
  57.  * These are strings that are used in various places
  58.  * in the program.  (Note that these are not really used
  59.  * in the example but are here for educational use...)
  60.  */
  61. /* TXT_Window_Title            */    "Font UI Example 2",
  62. /* TXT_AboutFontMover            */    "\rFont UI Example 2\n\rby\n\rMichael Sinz",
  63.  
  64. /* TXT_MakeDirPrompt            */    "Enter new directory name:",
  65. /* TXT_DirectoryTitleString        */    "Directory",
  66.  
  67. /* TXT_CopyFontOpenError        */    "\rCould not open source font file",
  68. /* TXT_CopyFontCopyError1        */    "\rError during generation of '",
  69. /* TXT_CopyFontCopyError2        */    "' destination",
  70.  
  71. /* TXT_AskRemove1            */    "\rAre you sure you wish to remove the '",
  72. /* TXT_AskRemove2            */    "' font family?",
  73. /* TXT_AskRemove3            */    "' size?",
  74.  
  75. /* TXT_RemoveFontError            */    "\rYou must select a font before you can REMOVE it",
  76.  
  77. /*
  78.  * These strings are used in the AlertUser calls
  79.  * and *MUST* be under 60 characters in length  (Should be 50 or less)
  80.  */
  81. /* TXT_OpenLayersError            */    "Could not open V33 layers.library",
  82. /* TXT_OpenGraphicsError        */    "Could not open V33 graphics.library",
  83. /* TXT_OpenDiskfontError        */    "Could not open V33 diskfont.library",
  84. /* TXT_OpenConsoleError            */    "Could not open console.device",
  85. /* TXT_GeneralMemoryError        */    "Out of memory",
  86. /* TXT_WindowOpenError            */    "Could not open FontMover window",
  87.  
  88. /* TXT_PressButtonToContinue        */    "Press right mouse button to continue",
  89.  
  90. /*
  91.  * If things go too far...
  92.  *
  93.  * This way, if any of the text display code has an error, the text
  94.  * it displays will be ERROR!
  95.  */
  96. /* STRING_TOO_FAR            */    "ERROR!"
  97. };
  98.  
  99. /*
  100.  * This function returns the string asked for...
  101.  *
  102.  * If you had various stings based on the language, this function
  103.  * would be used to return the correct language string.
  104.  */
  105. char *Get_String(short StringNum)
  106. {
  107.     if ((StringNum<0)||(StringNum>STRING_TOO_FAR)) StringNum=STRING_TOO_FAR;
  108.     return(All_Strings[StringNum]);
  109. }
  110.  
  111. /*
  112.  * This routine returns the maximum size of all of
  113.  * the text gadget strings given the TextAttr
  114.  *
  115.  * Note that this is used to make sure that all of my gadget buttons
  116.  * are the same size.  In some displays you may need a few of these
  117.  * functions as you will have different button sizes.
  118.  */
  119. short Max_Gadget_Length(struct TextAttr *ta)
  120. {
  121. register    short        Width=0;
  122. register    short        loop;
  123. register    short        tmp;
  124.     struct    IntuiText    IText;
  125.  
  126.     memset(&IText,0,sizeof(struct IntuiText));
  127.  
  128.     IText.ITextFont=ta;
  129.     for (loop=TXT_CopyRightString;loop<TXT_DirSelectGadget;loop++)
  130.     {
  131.         IText.IText=Get_String(loop);
  132.         if ((tmp=IntuiTextLength(&IText)) > Width) Width=tmp;
  133.     }
  134.     return(Width);
  135. }
  136.